<template>
	<view>
		<view v-for="(item,index) in res" :key="index" style="padding: 0 20upx;background-color: #FFFFFF;border-radius: 10upx;margin-top: 5upx;border-bottom: 2upx solid #eeeeee;position: relative;box-shadow: 2upx 2upx 10upx #CCCCCC;" >
			<view style="padding: 0 20upx;">
				
				<view  style="position: relative; width: 100%;color: #666;">
					<view style="height: 60upx;line-height: 90upx;padding-left: 20upx;font-size: 34upx;">
						获得业绩
					</view>
					<view style="height: 65upx;padding-left: 20upx;">
						<text style="font-size: 20upx;">{{item.time}}</text>
					</view>
					<view class="act">
						+{{item.yeji}}
					</view>
				</view>
				
				<!-- <view style="min-height: 80upx;line-height: 80upx;color: #ff5500;" v-if="item.remark != ''">
					<text style="color: #ccc;">驳回理由</text>
					<text style="padding-left: 40upx;">{{item.remark}}</text>
				</view> -->
			</view>
			
		</view>
		<uni-load-more :loadingType="loadingType" :contentText="contentText"></uni-load-more>
	</view>
</template>

<script>
	import uniLoadMore from '@/components/uni-load-more.vue';
	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				res:[],
				openid:'',
				
				loadingText: '加载中...',
				loadingType: 0,
				contentText: {
					contentdown: '上拉显示更多',
					contentrefresh: '正在加载...',
					contentnomore: '没有更多数据了'
				},
				page: 1,
				timer:{},
			};
		},
		onLoad:function(){
			uni.showLoading()
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data
					this.setAjax()
				},
				fail: () => {
					uni.navigateTo({
						url: '../../../index/index'
					});
				}
			});
		},
		onPullDownRefresh() {
			this.page = 1
			this.loadingType = 0;//将loadingType归0重置
			this.setAjax()
			setTimeout(function () {
					uni.stopPullDownRefresh();
			}, 1000);
		},
		onReachBottom(){
			if (this.timer != null) {
				clearTimeout(this.timer)
			}
			this.timer = setTimeout(()=> {
				this.getmorenews()
			}, 1000);
		},
		methods:{
			setAjax(){
				uni.request({
					url: 'https://bhh.ax1319.com/app/index.php?i=4&c=entry&m=ewei_shopv2&do=mobile&r=member.yj_log&app=1&page=1',
					method: 'POST',
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					data:{
						'openid':this.openid
					},
					success: res => {
						console.log(res)
						this.res = res.data.shouyi
						console.log(this.res)
					},
					fail: () => {},
					complete: () => {}
				});
				uni.hideLoading()
			},
			getmorenews() {
				this.page++;//每触底一次 page +1
				if (this.loadingType !== 0) {//loadingType!=0;直接返回
					return false;
				}
				this.loadingType = 1;
				uni.showNavigationBarLoading();//显示加载动画
				uni.request({
					url: 'http://taiyou.mygodmall.com/app/index.php?i=4&c=entry&m=ewei_shopv2&do=mobile&r=member.fenxiang&app=1&page=' + this.page,
					method: 'POST',
					data:{
						openid: this.openid,
					},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: res => {
						uni.hideLoading()
						if (res.data.shouyi == '' || res.data.shouyi == null) {//没有数据
							this.loadingType = 2;
							uni.hideNavigationBarLoading();//关闭加载动画
							return;
						}
						this.res = this.res.concat(res.data.shouyi);//将数据拼接在一起
						this.loadingType = 0;//将loadingType归0重置
						uni.hideNavigationBarLoading();//关闭加载动画
					},
					fail: () => {},
					complete: () => {}
				});
			},
			jump(e){
				uni.navigateTo({
					url: e.currentTarget.dataset.src
				});
			},
		}
	}
</script>

<style>
	.act {
		position: absolute;
		top: 35upx;
		right: 30upx;
		color: #8E0447;
		font-size: 34upx;
	}
</style>

